<?php
/**
 * 命令行具体执行程序
 * 1)必须放置于cli/script目录下
 * 2)文件名必须为小写的cli_xxxx.php
 * 3)类名必须为Cli_Xxxx格式
 * 4)必须包含一个run($args)方法,$args为自动转换后的命令行参数
 *
 * 调用方法:
 * <code>
 * cli script=demo username=sharmy
 * </code>
 *
 * 命令行应用示例
 *
 * @author Chengtian.Hu<chengtian.hu@gmail.com>
 */

class Cli_taobaocheck{
    public function run($args){
    		
    		set_time_limit(0);
    		$session = $this->_loadtoken();
    		
    		require_once dirname(__FILE__).'/../../lib/top/TopClient.php';
			require_once dirname(__FILE__).'/../../lib/top/request/TradeFullinfoGetRequest.php';
			require_once dirname(__FILE__).'/../../lib/top/request/LogisticsDummySendRequest.php';
			require_once dirname(__FILE__).'/../../lib/top/RequestCheckUtil.php';
			$c = new TopClient;
			$c->appkey = '21612259';
			$c->secretKey = '39a31b83172056116d82ac8af7ad7a4b';
			
			$req = new TradeFullinfoGetRequest;
			$req->setFields("status,num,total_fee,price");
			$req->setTid('252032399702533');
			$querytaobao = $c->execute($req,$session);
			Helper_Common::log('TAOBAO-CHECK RESULT:'.print_r($querytaobao,true),__CLASS__);
			dump($querytaobao);
    }
    function _loadtoken()
    {
    	$taobao = Acct::find('id = 1')->setColumns('id,tbtoken')->getOne();
    	return trim($taobao->tbtoken);
    }
}